<template>
	<view class="news">
		<news-item :news=news @newsClick="gotoDetail"></news-item>
	</view>
</template>

<script>
	import newsItem from '../../component/news-item/news-item.vue';
	export default {
		data() {
			return {
				news:[]
			}
		},
		components:{
			"news-item": newsItem
		},
		onLoad(){
			this.getNews();
		},
		methods: {
			gotoDetail(id){
				console.log("查看news详情界面:", id);
				uni.navigateTo({
					// id作为参数传给news-detail页面
					url: "./news-detail/news-detail?id=" + id,
				})
			},
			getNews(){
				this.news = [
					{
						id: 1,
						imgUrl: "../../static/img/1.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-9-22",
						viewCount: 998
					},
					{
						id: 2,
						imgUrl: "../../static/img/2.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-10-22",
						viewCount: 1024
					},
					{
						id: 3,
						imgUrl: "../../static/img/3.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-8-22",
						viewCount: 3369
					},
					{
						id: 4,
						imgUrl: "../../static/img/1.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-9-22",
						viewCount: 998
					},
					{
						id: 5,
						imgUrl: "../../static/img/2.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-10-22",
						viewCount: 1024
					},
					{
						id: 6,
						imgUrl: "../../static/img/3.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-8-22",
						viewCount: 3369
					},
					{
						id: 7,
						imgUrl: "../../static/img/1.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-9-22",
						viewCount: 998
					},
					{
						id: 8,
						imgUrl: "../../static/img/2.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-10-22",
						viewCount: 1024
					},
					{
						id: 9,
						imgUrl: "../../static/img/3.jpg",
						title: "这是标题！！！这是标题！！！这是标题！！！这是标题！！！这是标题！！！",
						releaseDate: "2021-8-22",
						viewCount: 3369
					}
				];
			}
		}
	}
</script>

<style lang="scss">
.news{

}
</style>
